package com.ruoyi.test.task;

import com.ruoyi.good.persistent.dao.IGoodSkuDao;
import com.ruoyi.good.repository.IActivityRepository;
import com.ruoyi.good.service.ISkuStock;
import com.ruoyi.task.model.entity.TaskEntity;
import com.ruoyi.task.persistent.dao.ITaskDao;
import com.ruoyi.task.persistent.po.Task;
import com.ruoyi.task.service.ITaskService;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * TODO
 *
 * @Description
 * @Author wkm
 * @Date 2024/12/28
 **/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class ApiTest {
    @Resource
    private ITaskService taskService;

    @Resource
    private ITaskDao taskDao;
    @Resource
    private IGoodSkuDao goodSkuDao;
    @Resource
    private ISkuStock skuStock;
    @Resource
    private IActivityRepository activityRepository;
    @Before
    public void setUp(){
        log.info("装配活动：{}", skuStock.assembleGoodSku(1005L));
    }
    @Test
    public void insert(){
        for(int i = 21;i <= 40;i ++ ){
            Task task = new Task();
            task.setUserId("1");
            task.setTopic("SendMessage");
            task.setMessageId(String.valueOf(i));
            task.setMessage("发送MQ");
            task.setState("create");
            taskDao.insert(task);
        }
    }
    @Test
    public void test_queryTaskNoSendList(){
        List<TaskEntity> taskEntities = taskService.queryNoSendMessageTaskList();
        for (TaskEntity taskEntity : taskEntities){
            log.info(taskEntity.toString());
        }
    }

    @Test
    public void skuStockTest(){
        for (int i = 1;i <= 10;i ++ ){
            activityRepository.subtractionGoodSkuStock(1005L,"activity_sku_stock_count_key_1005", new Date(1735257600));
        }
    }
}
